package com.eling.elcms.travel.webapp.controller;

import com.eling.elcms.core.dao.hibernate.search.SearchCondition;
import com.eling.elcms.core.webapp.controller.BaseFormController;
import com.eling.elcms.core.webapp.controller.Msg;
import com.eling.elcms.core.webapp.spring.ModelFilling;
import com.eling.elcms.travel.model.ApprovalRuleRegister;
import com.eling.elcms.travel.service.IApprovalRuleRegisterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

@Controller
public class ApprovalRuleRegisterController extends BaseFormController{
	
	@Autowired 
	private IApprovalRuleRegisterService service;
	
	
	@RequestMapping("/api/approvalruleregister/save")
	@ResponseBody
	public ApprovalRuleRegister save(@ModelAttribute@ModelFilling ApprovalRuleRegister approvalRuleRegister) {
	  return service.save(approvalRuleRegister);
	}
	
	
	@RequestMapping("/api/approvalruleregister/{pkApprovalRuleRegister}/delete")
	@ResponseBody
	public Msg delete(@PathVariable Long pkApprovalRuleRegister) {
		service.remove(pkApprovalRuleRegister);
	   return new Msg("删除成功");
	}
	
	    
	@RequestMapping("/api/approvalruleregister/query")
	@ResponseBody
	public List<ApprovalRuleRegister> query(@ModelAttribute ApprovalRuleRegister cond){
		return service.query(cond);
	  }
	
	@RequestMapping("/api/approvalruleregister/search*")
	@ResponseBody
	public List<ApprovalRuleRegister> search(@ModelAttribute SearchCondition sc){
		return service.search(sc);
	 }
	
	@RequestMapping("/api/approvalruleregister/findCandidatePara")
	@ResponseBody
	public Map<String, String> findCandidatePara(@ModelAttribute@ModelFilling ApprovalRuleRegister cond){
		return service.findCandidatePara(cond);
	 }
}
